package it.polimi.swim.entity;
import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@NamedQueries({
	@NamedQuery(
		name="HelpRequest.getNewHelpRequestById",
		query="SELECT h FROM HelpRequest h WHERE h.id = :id AND h.status=0"),
	@NamedQuery(
			name="HelpRequest.getHelpRequestById",
			query="SELECT h FROM HelpRequest h WHERE h.id = :id"),
	@NamedQuery(
			name="HelpRequest.DeteleHelpRequest",
			query="DELETE FROM HelpRequest h WHERE h.id = :id")
})

@Entity
@Table(name="HelpRequest")
public class HelpRequest implements Serializable {
	
	private static final long serialVersionUID = -818770057503416916L;

	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private int id;

	@Column(name="description",nullable=false)
	private String description;
	
	@Column(name="status",nullable=false)
	private boolean status;

	@Column(name="title",nullable=false)
	private String title;
	
	
	@ManyToOne(fetch=FetchType.EAGER)
    @JoinColumn(name="creator", nullable=false)
	private SystemUser creator;
	
	@OneToOne
	private Feedback feedback;
    @JoinColumn(name="feedback")
    
    public Feedback getFeedback() { return feedback; }
    public void setFeedback(Feedback f) { feedback=f; }

	public SystemUser getIdCreator() {
		return creator;
	}
	public void setIdCreator(SystemUser idCreator) {
		this.creator = idCreator;
	}
	//
	
	@ManyToOne(fetch=FetchType.EAGER)
    @JoinColumn(name="receiver")
	private SystemUser receiver;
	
	@ManyToOne
    @JoinColumn(name="necessarySkill")
	private Skill necessarySkill;
	
	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	public String getDescription() {
		return description;
	}


	public void setDescription(String description) {
		this.description = description;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public SystemUser getReceiver() {
		return receiver;
	}

	public void setReceiver(SystemUser receiver) {
		this.receiver = receiver;
	}

	public Skill getNecessarySkill() {
		return necessarySkill;
	}

	public void setNecessarySkill(Skill necessarySkill) {
		this.necessarySkill = necessarySkill;
	}

	public boolean isStatus() {
		return status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}
}
